package com.polytech.dao.hibernate;

import java.util.Collection;
import java.util.List;

import com.polytech.beans.Category;
import com.polytech.dao.CategoryDao;

public class CategoryDaoHibernate extends AbstractHibernateDao implements CategoryDao {

	@Override
	public void insert(Category category) {
		beginTransaction();
			session.save(category);
		commit();
	}

	@Override
	public Category select(String key) {
		beginTransaction();
			Category category=(Category)session.get(Category.class,key);
		commit();
		return category;
	}

	@Override
	public void remove(Category category) {
		beginTransaction();
			session.delete(category);
		commit();
	}

	@Override
	public Collection<Category> selectAll() {
		List<Category> res=null;
		beginTransaction();
			res  = (List<Category>) session.createQuery("from Category").list();
		commit();
		return res;
	}
	
	
}
